<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>五子棋</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        html, body {
            width: 100%;
            height: 100%;
        }

        .GoBang {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }
        #chessboard{
            width: 435px;
            height: 435px;
        }

    </style>
</head>
<body>
<div class="GoBang">
    <canvas id="chessboard"></canvas>
</div>

<script>
    let chessboard = document.getElementById('chessboard');
    let ctx = chessboard.getContext('2d');

    console.log(ctx.width);

    if (ctx) {
        drawingBoard(ctx);
    } else {
        alert('该浏览器不支持canvas');
    }


    /**
     * 绘制棋盘
     */
    function drawingBoard(ctx) {


        for (let i = 0; i < 15; i++) {

            ctx.moveTo(15 + i * 30, 15);
            ctx.lineTo(15 + i * 30, 435);
            ctx.stroke();

            ctx.moveTo(15, 15 + i * 30);
            ctx.lineTo(435, 15 + i * 30);
            ctx.stroke();
        }
    }


</script>
</body>
</html>